<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8" language="java"
	import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/base.jsp"%>
<%@ taglib prefix="d" uri="/doone-comm-ui-tags"%>

<html>
	<head>
		<title>应用信息管理</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<link type="text/css" href="<%=path%>/manage/css/layout.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/manage/css/Tooltip.css" />
        <link type="text/css" href="<%=path%>/manage/css/new_style.css" rel="stylesheet" />
        
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery-1.4.4.min.js"></script>

		<script type="text/javascript"
			src="<%=path%>/manage/js/easyTooltip.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery-ui-1.8.11.custom.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.wysiwyg.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/hoverIntent.js"></script>
		<script type="text/javascript" src="<%=path%>/manage/js/superfish.js"></script>
		<script type="text/javascript" src="<%=path%>/manage/js/custom.js"></script>
			<script type="text/javascript" src="<%=path %>/manage/js/My97DatePicker/WdatePicker.js"></script>
		<%-- 验证js Start --%>
		<script type="text/javascript" src="<%=path%>/manage/js/Tooltip.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.methods.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.defaults.js"></script>
	  <script type="text/javascript" src="<%=path%>/manage/js/errorTip.js"></script>
	</head>
	</head>

	<script type="text/javascript">
	//应用编辑	
	function editApp(intAppOsType) {
		$.ajax({
			url : root + '/app/goEditAppInfoById.action',
			method : 'post',
			dataType : 'json',
			data : {
				'intAppOsType' : intAppOsType
			},
			success : function(data) {
				//给form的文本赋值
				//应用名称		
				$("#varAppName").attr("value", data.varAppName);
				//应用描述
				$("#varAppDescript").attr("value", data.varAppDescript);
				//应用开始时间
				$("#datAppServStarttime").attr("value",data.datAppServStarttime);
						//应用结束时间
				$("#datAppServEndtime").attr("value",data.datAppServEndtime);
				//LODING图标
				$("#imgFile").attr("src", data.varIconUrl);
				//应用类型
				$("#varAppOsTypeName").attr("value", data.varAppOsTypeName);
				//应用服务金额
				$("#dobAppMoney").attr("value", data.dobAppMoney);
				//应用下载次数
				$("#intAppDownCount").attr("value", data.intAppDownCount);	
				$("#intAppOsType").attr("value",data.intAppOsType);	
				$("#intAppId").attr("value",data.intAppId);			

				//打开dialog
				$("#appDialog").dialog("open");
			},
			error : function(err) {
				if (err.responseText != '')
					alert(err.responseText);
				else
					alert("请求失败！");
			}
		});
	}
	//企业信息删除
	function delApp(intAppOsType) {
		if (confirm("慎重考虑是否确定删除该记录?删除后无法查看该条记录！！！")) {
			$.ajax({
				url : root + '/app/doDelApp.action',
				method : 'post',
				data : {
					'intAppOsType' : intAppOsType
				},
				success : function(data) {

					window.location.href = root
							+ '/app/getAppInfo.action';
				},
				error : function(err) {
					if (err.responseText != '')
						alert(err.responseText);
					else
						alert("请求失败！");
				}
			});
		}
	}
	
	//检测文件格式
	var flag = true;
	function validateFile(obj) {       
		
		    var filepath = obj.value;
		
			var fileArr = filepath.split("\\");
			var fileTArr = fileArr[fileArr.length - 1].toLowerCase().split(".");
			var filetype = fileTArr[fileTArr.length - 1];
			if (filetype != "jpg" && filetype != "png") {
				$(obj).addErrorMessage("必须上传jpg、png格式的文件");					
				flag = false;
			} else {
				 $(obj).removeErrorMessage();	
				 flag = true;
			}
	}
	$(document).ready(function() {
      //验证
		var editAppForm = $("#editAppForm").validate({
			rules : {
				"appManageDto.varAppName" : {
					required : true
				},
				"appManageDto.varAppDescript" : {
					required : true
					}		
							},
			messages : {
				"appManageDto.varAppName" : {
					required : "应用名称必填"
				},
				"appManageDto.varAppDescript" : {
					required : "应用描述"
				}
				
				
			}
		});
		//加载dialog
		$("#appDialog").dialog({
			autoOpen : false,
			width : 800,
			height : 350,
			modal : true,
			title : '企业信息编辑',
			buttons : {
				"保存" : function() {
				if(!editAppForm.valid()){
				alert("数据验证为通过，无法保存");
				}else if(!flag){
				 alert("上传文件格式错误");
				}else{
					$("#editAppForm").submit();
					$(this).dialog("close");
					}
					
				},
				"取消" : function() {
					$(this).dialog("close");
					$("#editAppForm")[0].reset();
				}
			},
			close : function() {
				$("#editAppForm")[0].reset();
			}
		});		
	});

	function getMicroBo(intAppId) {
		window.location.href = root + '/app/getMicroBoInfo.action';
	}
</script>

	<body>
		<div>
			<p class="sitemap">
				当前位置：内容管理 > 应用信息管理
			</p>
			<h1>
				应用信息管理
			</h1>
			<div>
				<!-- Tabs -->
				<div id="tabs">
					<ul>
						<li>
							<a href="#tabs-1">应用列表</a>
						</li>

					</ul>
		<!-- 检索 -->	
		<!-- 检索 END-->					
				<table class="fullwidth" cellpadding="0" cellspacing="0" id="enterInfoTab">
					<thead>
						<tr>
						<td>loading图标</td>
							<td>
								应用名称
							</td>
							<td>
								应用描述
							</td>
							<td>
								版本号
							</td>
							<td>
								应用有效时间
							</td>
							<td>
								应用类型
							</td>
							<td>
								应用服务金额
							</td>
							<td>
								应用下载次数
							</td>							
							<td>
								操作
							</td>
						</tr>
						</thead>
                       <tbody>
						<s:iterator value="appList">
							<tr class="odd">
							<td>
									<img alt="loading图标"
										src="<s:property value="varIconUrl" />" width="76"
										height="53">
								</td>
								<td>
									<s:property value="varAppName" />
								</td>
								<td>
									<s:property value="varAppDescript" />
								</td>
								<td>
									<s:property value="dobAppVersion" />
								</td>
								<td>
									<s:property value="datAppServStarttime" />~<s:property value="datAppServEndtime" />
								</td>
								
								<td>
									<s:property value="varAppOsTypeName" />
								</td>
								<td>
									<s:property value="dobAppMoney" />
								</td>
								<td>
									<s:property value="intAppDownCount" />
								</td>
								<td>
								

									<a class="icon icon_edit" title="编辑 " href="javascript:editApp('<s:property value="intAppOsType" />')"></a>
									<%-- 
									<a class="icon icon_delete" title="删除" href="javascript:delApp('<s:property value="intAppOsType" />')"></a>
									--%>
									<a class="icon icon_house" title="查看微博" href="javascript:getMicroBo('<s:property value="intAppId" />')"></a>									

								</td>

							</tr>
						</s:iterator>
					</tbody>
				</table>
				</div>
				
		</div>
		</div>

		<!-- 编辑页使用的弹出层 -->
		<div id="appDialog" style="display: none;">
			<form action="<%=path%>/app/doEditApp.action"
				method="post" id="editAppForm" enctype=multipart/form-data>
				<s:hidden name="appManageDto.intAppId" id="intAppId"></s:hidden>
				<s:hidden name="appManageDto.intAppOsType" id="intAppOsType"></s:hidden>
				<table class="fullwidth" cellpadding="0" cellspacing="0" border="1">
					<tr>
						<td>
						应用名称
						</td>
						<td>
							<s:textfield name="appManageDto.varAppName"
								id="varAppName"></s:textfield>
							<span style="color: red">*</span>
						</td>
					</tr>
					<tr>
						<td>
							应用描述
						</td>
						<td>
							<s:textfield name="appManageDto.varAppDescript"
								id="varAppDescript"></s:textfield>
							<span style="color: red">*</span>
						</td>
						<td>
							应用有效时间
						</td>
						<td>
							<s:textfield name="appManageDto.datAppServStarttime"
								id="datAppServStarttime" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})"></s:textfield>——
								<s:textfield name="appManageDto.datAppServEndtime"
								id="datAppServEndtime" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})"></s:textfield>
							<span style="color: red">*</span>
						</td>
					</tr>
					<tr>
						<td>
							LODING图标
						</td>
						<td>
							<img src="" id="imgFile" width="54" height="32">
							<s:file name="myFile"  onblur="validateFile(this)"></s:file>
							<span style="color: red">*</span>
						</td>
					</tr>
					<tr>
						<td>
							应用类型
						</td>
						<td>
							<s:textfield name="appManageDto.varAppOsTypeName"
								id="varAppOsTypeName" readonly="true"></s:textfield>
							<span style="color: red">*</span>
						</td>

						<td>
							应用服务金额
						</td>
						<td>
							<s:textfield name="appManageDto.dobAppMoney"
								id="dobAppMoney"></s:textfield>
							<span style="color: red">*</span>
						</td>
					</tr>
					<tr>
						<td>
							应用下载次数
						</td>
						<td>
							<s:textfield name="appManageDto.intAppDownCount"
								id="intAppDownCount"></s:textfield>
							<span style="color: red">*</span>
						</td>
					</tr>
				</table>

			</form>
		</div>

	</body>
</html>
